package com.my.controller;

import com.my.domain.entity.Repair;
import com.my.domain.vo.TempVO;
import com.my.result.Result;
import com.my.service.RepairService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 维修表(Repair)表控制层
 *
 * @author makejava
 * @since 2022-04-11 13:27:26
 */
@RestController
@RequestMapping("/repair")
public class RepairController{

    @Autowired
    RepairService repairService;

    @RequiresPermissions("repair:*")
    @RequestMapping("/list")
    public Result getRepairs(@RequestParam(defaultValue = "1") Integer currentPage){
        return repairService.getRepairList(currentPage);
    }

    @RequestMapping("/bytime")
    public Result getRepairsByTime(){
        return repairService.getRepairByTime();
    }

    @RequiresPermissions("repair:*")
    @GetMapping("/delete")
    public Result deleteById(@RequestParam Long id){
        return repairService.deleteRepairById(id);
    }

    @RequiresPermissions("repair:*")
    @PostMapping("/add")
    public Result addRepair(@RequestBody TempVO temp){
        return repairService.addRepair(temp);
    }

}

